using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace MVCWeb.Controllers
{
    public class StaffController : BaseController
    {
        // GET: /Staff/Details/5
        [Authorize(Roles = "Administrators, PropertyManagers")]
        public ActionResult Details()
        {
            if (Session["CommunityId"] == null)
            {
                return RedirectToAction("Index", "SelectCommunity", new { returnUrl = Request.RawUrl });
            }

            int communityId = Convert.ToInt32(Session["CommunityId"]);
            ViewData["CommunityId"] = communityId;

            return View(dc.Contents.Where(x => x.ContentType == "STAFF").OrderByDescending(x => x.ID).First());
        }

        //
        // GET: /Staff/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Staff/Create

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Staff/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Staff/Edit/5

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
